package cn.wolfcode.luowowo.mgrsite.controller;

import cn.wolfcode.luowowo.comment.domain.TravelComment;
import cn.wolfcode.luowowo.comment.query.TravelCommentQuery;
import cn.wolfcode.luowowo.comment.service.IStrategyCommentService;
import cn.wolfcode.luowowo.comment.service.ITravelCommentService;
import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * 管理评论后台
 */
@Controller
@RequestMapping("/comment")
public class CommentController {
    @Reference
    private IStrategyCommentService strategyCommentService;
    @Reference
    private ITravelCommentService travelCommentService;

    @RequestMapping("/strategyCommentList")
    public String strategyCommentList(Model model) {
        Page page = strategyCommentService.findAll();
        model.addAttribute("page",page);
        return "comment/strategyCommentList";
    }

    @RequestMapping("/travelCommentList")
    public String travelCommentList(Model model) {
        TravelCommentQuery query = new TravelCommentQuery();
        query.setPageSize(Integer.MAX_VALUE);
        List<TravelComment> travelComments = travelCommentService.queryCommentForTen(query);
        PageHelper.startPage(1,5);
        PageInfo pageInfo = new PageInfo(travelComments);

        model.addAttribute("pageInfo",pageInfo);
        return "comment/travelCommentList";
    }
    @RequestMapping("/travelComment/delete")
    public String travelCommentDelete(String id) {

        return "";
    }
}
